package net.siufung.core.model.enums;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.siufung.core.model.EnumsVo;
import net.siufung.core.model.IEnum;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 陈建峰
 * @since 2021/11/29 5:43 下午
 */
@ToString
public enum DeletedEnum implements IEnum<Boolean> {

    /**
     * 启用
     */
    NOT(false, "启用"),
    /**
     * 禁用
     */
    IS(true, "禁用");

    @Getter
    @Setter
    private Boolean value;
    @Getter
    @Setter
    private String desc;

    DeletedEnum(boolean value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static DeletedEnum get(Boolean value) {
        return IEnum.get(DeletedEnum.class,
                enums -> enums.getValue().equals(value));
    }

    public static String getDesc(Boolean value) {
        return IEnum.getDesc(DeletedEnum.class,
                enums -> enums.getValue().equals(value));
    }

    public static List<EnumsVo> getList(){
        return IEnum.findList(DeletedEnum.class).stream()
                .map(element -> new EnumsVo(element.getValue(), element.getDesc()))
                .collect(Collectors.toList());
    }
}
